package fr.umlv.m2.jee.pmlv.persistence.planning;

import fr.umlv.m2.jee.pmlv.persistence.subject.Subject;
import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;



/**
 * Represents events in an university. An event can be a
 * lesson, an exam...
 * @author jenseric
 *
 */
@SuppressWarnings("serial")
@Entity
@Table(name="Event")
@Inheritance(strategy =InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn( name = "event_type", discriminatorType = DiscriminatorType.STRING)
public abstract class AbstractEvent implements Serializable {
	@Id
	@GeneratedValue
	@Column(name="event_id")
	private long id;

        @Temporal(TemporalType.TIMESTAMP)
	@Column(name ="event_begin")
	private Date begin;

        @Temporal(TemporalType.TIMESTAMP)
	@Column(name ="event_end")
	private Date end;
	
	@ManyToOne
	@JoinColumn(name="projector_id")
	private Projector projector;
	
	@ManyToOne
	@JoinColumn(name="classroom_id")
	private Classroom classroom;

        @OneToOne
	@JoinColumn(name="subject_id")
	private Subject subject;
	
	
	public void setId(long id) {
		this.id = id;
	}
	public long getId() {
		return id;
	}
	public void setBegin(Date begin) {
		this.begin = begin;
	}
	public Date getBegin() {
		return begin;
	}
	public void setEnd(Date end) {
		this.end = end;
	}
	public Date getEnd() {
		return end;
	}
	public void setProjector(Projector projector) {
		this.projector = projector;
	}
	public Projector getProjector() {
		return projector;
	}
	public void setClassroom(Classroom classroom) {
		this.classroom = classroom;
	}
	public Classroom getClassroom() {
		return classroom;
	}
        public void setSubject(Subject subject) {
		this.subject = subject;
	}
	public Subject getSubject() {
		return subject;
	}
}
